<!-- $Id: category_info.htm 16752 2009-10-20 09:59:38Z wangleisvn $ -->
{include file="pageheader.htm"}
{* 包含脚本文件 *}

<!-- start add new category form -->
<div class="main-div">
  <form action="kd_custom_goods_manage.php" method="post" name="theForm" >
  <table width="100%" id="general-table">
      <tr>
        <td class="label">站点网址:</td>
        <td>
          <select name="c_cate" id="c_cate" onchange="dochange(this)">
            <option value="0" ></option>
            {$category}
          </select> 
		  <select name="c_id" id="c_id">
            <option value="0" ></option>
            
          </select> 
		  <input type="button" value="保存" onclick="checkthis()" />
        </td>
		
      </tr>
    </table>
	  <div class="button-div">
    <input type="hidden" name="act" value="add" />    
        
      </div>
  </form>
	  <table>
      <tr>
        <td class="label">编号</td>
        <td>分类</td>
        <td>&nbsp;</td>
      </tr>
{foreach from=$cgdata item=cd}
      <tr>
        <td class="label">{$cd.id}</td>
        <td>{$cd.goods_name}</td>
        <td>{$cd.memo}
		<span><a href="?act=del&id={$cd.id}" >删除</a></span>
		</td>
      </tr>
{/foreach}
      <tr>
        <td class="label">&nbsp;</td>
        <td>&nbsp;</td>
        <td>&nbsp;</td>
      </tr>

      <tr>
        <td class="label">&nbsp;</td>
        <td>&nbsp;</td>
        <td>&nbsp;</td>
      </tr>
      </table>
      
</div>
{literal}
<script language="JavaScript">
<!--

/**
 * 检查表单输入的数据
 */
function checkthis()
{
    
  var obj = document.getElementById('c_id');
  if(obj.value == '0'){
	  alert('请选择商品');  
	  return false;
  }  
  //alert(obj.value);
  document.theForm.submit();

}

/**
 *
 */
function dochange(evn){
	var params = "cid="+evn.value;
	Ajax.call('getGoodsFromCate.php', params, getGoodsResponse, 'POST', 'TEXT', true, false);
}

function getGoodsResponse(result){
	var obj = document.getElementById('c_id');
	//alert(result);
	if(result != '[]'){
		var json = eval("("+result+")");
		obj.options.length = 0;
		var objOption = document.createElement("OPTION");
		objOption.text = '';
		objOption.value = 0;
		obj.options.add(objOption); 
		var i = 0;
		for(i; i<json.length; i++){
			var objOption = document.createElement("OPTION");
			objOption.text = json[i].goods_name;
			objOption.value = json[i].goods_id;
			obj.options.add(objOption); 
		}
	}else{
	 	obj.options.length = 0;
		var objOption = document.createElement("OPTION");
		objOption.text = '';
		objOption.value = 0;
		obj.options.add(objOption); 
	}
}

//-->
</script>
{/literal}
{include file="pagefooter.htm"}